/* eslint-disable no-undef */
import React, { useState, useEffect } from 'react';
import { Form } from 'antd';
import { useHistory } from 'react-router-dom';
import qs from 'qs';
import { If, For } from 'babel-plugin-jsx-control-statements';
import RequestApi from '@/utils/request';
import css from '../index.scss';

/**
 * 停车管理备案中我的备案中相关附件详情
 * -
 */
export default () => {
	const [data, setData] = useState();
	const history = useHistory();
	const search = qs.parse(history.location.search, { ignoreQueryPrefix: true });
	const { id } = search;
	useEffect(() => {
		RequestApi.connection('get', `parkLotRecordTask/parkLotTaskInfo/${id}`).then((response) => {
			setData(response.data.rows.parkLotAttachmentsInfoDTO);
		});
		// eslint-disable-next-line react-hooks/exhaustive-deps
	}, []);
	return (
		<If condition={data !== undefined}>
			<div>
				<Form.Item label="停车场产权单位证明:" className={css.item_file}>
					<If condition={data.propertyRight !== null}>
						<For each="item" of={data.propertyRight}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item label="使用权证明材料:" className={css.item_file}>
					<If condition={data.applicationRecordForm !== null}>
						<For each="item" of={data.applicationRecordForm}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item className={css.item_file}>
					<></>
				</Form.Item>
				<Form.Item label="管理单位工商营业执照:" className={css.item_file}>
					<If condition={data.businessLicense !== null}>
						<For each="item" of={data.businessLicense}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item label="单位授权办件委托书:" className={css.item_file}>
					<If condition={data.recommendation !== null}>
						<For each="item" of={data.recommendation}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item className={css.item_file}>
					<></>
				</Form.Item>
				<Form.Item label="建设工程规划竣工验收备案登记证:" className={css.item_file}>
					<If condition={data.confirmationOfCompletion !== null}>
						<For each="item" of={data.confirmationOfCompletion}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item className={css.item_file}>
					<></>
				</Form.Item>
				<Form.Item className={css.item_file}>
					<></>
				</Form.Item>
				<Form.Item label="交通组织图:" className={css.item_file}>
					<If condition={data.trafficOrganisationChart !== null}>
						<For each="item" of={data.trafficOrganisationChart}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item className={css.item_file}>
					<></>
				</Form.Item>
				<Form.Item className={css.item_file}>
					<></>
				</Form.Item>
				<Form.Item label="停车场设施清单:" className={css.item_file}>
					<If condition={data.parkLotSettingList !== null}>
						<For each="item" of={data.parkLotSettingList}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item className={css.item_file}>
					<></>
				</Form.Item>
				<Form.Item className={css.item_file}>
					<></>
				</Form.Item>
				<Form.Item label="经营服务及安全管理制度:" className={css.item_file}>
					<If condition={data.serviceAndSafeSystem !== null}>
						<For each="item" of={data.serviceAndSafeSystem}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item label="管理运营维护方案:" className={css.item_file}>
					<If condition={data.manageOperateMaintainProject !== null}>
						<For each="item" of={data.manageOperateMaintainProject}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item label="应急处理预案:" className={css.item_file}>
					<If condition={data.emergencyResponsePlan !== null}>
						<For each="item" of={data.emergencyResponsePlan}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
				<Form.Item label="其他:" className={css.item_file}>
					<If condition={data.others !== null}>
						<For each="item" of={data.others}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
			</div>
		</If>
	);
};
